<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>商品列表</title>
	<meta name="decorator" content="default"/>
	<style type="text/css">
		.table td {
			vertical-align: middle;
			background-color: #FFF;
			border: 0px;
			padding: 0px;
		}
		.bg_white{background-color: white; color: red;}
		#sortSearch li{border-right: 1px solid #DDD;padding: 5px 15px;list-style-type:none;float: left;}
		.twoClass label{border: 1px solid #DDD; margin-left: 0px; margin-top: 5px;padding: 0px 5px;}
		.bg_color{background-color: #A1A1FF;}
		#one li a{padding-top: 0px; padding-bottom: 0px;}
	</style>
	<script type="text/javascript">
		var _lastPage="false";
		var $selectAll = false;//全选标记
		var _count = ${count};//记录总数
		$(document).ready(function() {
			_lastPage = ${page.lastPage};
			if(_lastPage){
				var loadHtml = "<p>已加载全部数据...<p>";
				$(".loadMore").html(loadHtml);
			}
			$("#searchForm").validate({
				submitHandler: function(form){
					$("#pageNo").val(1);
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element.parent());
					}
				}
			});
			$("#listForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			if($("#type").val()!="1"){
				$("tr[id='moreCondition']").each(function(){
					$(this).hide();
				});
			}else{
				$("#lable_more").html("︽收起");
			}
			if($("#sortName").val() != ''){
				initShowSort($("#sortName").val(),$("#orderBy").val());
			}
			
			// 定义一个新的复制对象
			var clip = new ZeroClipboard($("a[id='clip_button']"), {
			  moviePath: "${ctxStatic }/ZeroClipboard/ZeroClipboard.swf"
			} );
			
			// 复制内容到剪贴板成功后的操作
			clip.on( 'complete', function(client, args) {
			   alert("复制成功，请到剪贴板粘帖！");
			} );
			gotoTop();
		});
		//初始化显示排序
		function initShowSort(name,orderBy){
			if(name == 'sort'){//根据排序号排序
				$("#sortSearch li:eq(0)").addClass("bg_white");
				var val = $("#sortSearch li:eq(0)").text();
				if(orderBy == "asc"){
					$("#sortSearch li:eq(0)").text(val+"︿");
				}else if(orderBy == "desc"){
					$("#sortSearch li:eq(0)").text(val+"﹀");
				}
			}else if(name == 'name'){//根据商品名排序
				$("#sortSearch li:eq(1)").addClass("bg_white");
				var val = $("#sortSearch li:eq(1)").text();
				if(orderBy == "asc"){
					$("#sortSearch li:eq(1)").text(val+"︿");
				}else if(orderBy == "desc"){
					$("#sortSearch li:eq(1)").text(val+"﹀");
				}
			}else if(name == 'price'){//根据价格排序
				$("#sortSearch li:eq(2)").addClass("bg_white");
				var val = $("#sortSearch li:eq(2)").text();
				if(orderBy == "asc"){
					$("#sortSearch li:eq(2)").text(val+"︿");
				}else if(orderBy == "desc"){
					$("#sortSearch li:eq(2)").text(val+"﹀");
				}
			}
		}
		var isLoadOver=0;//判断滑动是否已加载完成
		$(window).scroll(function(){  
		    // 当滚动到最底部以上100像素时， 加载新内容  
		    if ($(document).height() - $(this).scrollTop() - $(this).height()<100){
		    	if(isLoadOver == 0){
		    		isLoadOver = 1;
			    	//loadMore();  
			    	$(".loadMore").show();
		    	}
		    }
		}); 
		//加载更多-全部
		function loadMore(){
			if(_lastPage){
				return;
			}
			if(_count>=60){
				top.$.jBox.confirm("剩余未加载记录:"+(parseInt(_count)-10)+"条，全部加载预计需要1分钟，是否继续？","系统提示",function(v,h,f){
					if(v=="ok"){
						loadMoreList();
					}
				},{buttonsFocus:1});
				top.$('.jbox-body .jbox-icon').css('top','55px');
			}else{
				loadMoreList();
			}
		}
		function loadMoreList(){
			loading('正在加载，请稍等...');
			setTimeout(function () {
				//获取下一页数据
				$("#pageNo").val(parseInt($("#pageNo").val())+1);
				$("#pageSize").val(9999);
				var param = "pageNo="+$("#pageNo").val()+"&pageSize=9999";
				param += "&oneClassify="+$("#oneClassify").val();
				param += "&twoClassify="+$("#twoClassify").val();
				param += "&sortName="+$("#sortName").val();
				param += "&orderBy="+$("#orderBy").val();
				param += "&openState="+$("#openState").val();
				param += "&toPay="+$("#toPay").val();
				param += "&isPurchase="+$("#isPurchase").val();
				param += "&stockState="+$("#stockState").val();
				param += "&searchParam="+URLencode($("#searchParam").val());
				//异步获取更多
				$.ajax({
					type: 'post',
					url: '${ctx}/ivm/product/list/more',
					data: param,
					dataType: 'json',
					success: function(data){
						if(data!=null){
							var list = data.list;
							if(data.lastPage){
							 	_lastPage = data.lastPage;
							}
							for(var i=0; i<list.length; i++){
								if(i<10){
									continue;
								}
								var product = list[i];
								var html = '<table id="contentTable" class="table table-bordered table-condensed" style="border-top: 0px;margin-bottom:5px">';
								html += '<colgroup><col width="50px"><col width="169px"/><col width="119px"/><col width="119px"/><col width="119px"/><col width="119px"/><col width="119px"/><col width="305px"/></colgroup>';
								html += '<tr>';
								html += '<td rowspan="5" style="text-align: center;"><input type="checkbox" id="productId" name="productId" value="'+product.id+'" /></td>';
								html += '<td rowspan="5"><a href="javascript:" onclick="editForm(\''+product.id+'\')"><img id="photo" src="${ctx}/download?filePath='+product.logoUrl+'" style="width:149px;height:96px " /></a></td>';
								html += '<td>'+product.code+'</td>';
								html += '<td colspan="2"><a href="javascript:" onclick="editForm(\''+product.id+'\')">'+product.name+'</a></td>';
								html += '<td><label class="color-green" onclick="openSaleState(\''+product.id+'\')">';
								if(product.openState==1){
									html += '正在销售';
								}else{
									html += '待售';
								}
								html += '</label></td>';
								html += '<td><label class="color-green" onclick="openIntoInventory(\''+product.id+'\')">入库</label></td>';
								html += '<td rowspan="5">';
								html += '<input type="hidden" name="ids" value="'+product.id+'"/>';
								//html += '排序号：<input name="sorts" type="text" value="'+product.sort+'" style="width:50px;margin:0;padding:0;text-align:center;" class="required digits">';
								html += '<a href="javascript:" id="arrow-up" onclick="arrowUpTable(this)"><i class="icon-arrow-up"></i>上移</a>';
								html += '<a href="javascript:" id="arrow-down" onclick="arrowDownTable(this)"><i class="icon-arrow-down"></i>下移</a>';
								html += '</td>';
								html += '</tr><tr><td></td>';
								html += '<td colspan="2">'+product.assisTitle+'</td>';
								html += '<td><label class="color-green" onclick="showProductSupplier(\''+product.id+'\')">销售市场</label></td>';
								html += '<td><label class="color-green" onclick="openOutInventory(\''+product.id+'\')">库存处理</label></td>';
								html += '</tr><tr>';
								html += '<td>原价：<label class="color-green" onclick="openPrice(\''+product.id+'\', \''+product.name+'\', 1)">'+product.originalPrice+'</label>元</td>';
								html += '<td>现价：<label class="color-green" onclick="openPrice(\''+product.id+'\', \''+product.name+'\', 2)">'+product.price+'</label>元</td>';
								html += '<td>进价：<label class="color-green" onclick="openPrice(\''+product.id+'\', \''+product.name+'\', 3)">'+product.tradePrice+'</label>元</td>';
								html += '<td><label class="color-green" onclick="openPayState(\''+product.id+'\')">';
								if(product.toPay=='0'){
									html += '网付';
								}else{
									html += '网付/到付';
								}
								html += '</label></td>';
								html += '<td><label class="color-green" onclick="showInOrOutDetail(\''+product.id+'\', \''+product.name+'\')">进出库记录</label></td>';
								html += '</tr><tr>';
								var price1 = product.price;
								var price2 = product.tradePrice;
								var price3 = product.originalPrice;
								var acc = accSub(parseFloat(price1),parseFloat(price2));
								html += '<td>毛利：'+acc+'</td>';
								var rate = accDiv(accMul(acc,100),price2);
								html += '<td>毛利率：'+rate+'%</td>';
								html += '<td>损耗率：'+product.lossRate+'</td>';
								if(product.purchaseNum==0){
									html += '<td>不限购</td>';
								}else{
									html += '<td>限购数量：'+product.purchaseNum+'</td>';
								}
								html += '<td></td>';
								html += '</tr><tr>';
								if(product.productUnit==null){
									html += '<td>售出：'+product.saleNum+'</td>';
								}else{
									html += '<td>售出：'+product.saleNum+product.productUnit.name+'</td>';
								}
								html += '<td>浏览：'+product.scan+'</td>';
								html += '<td>库存：'+product.stock+'</td>';
								html += '<td colspan="2"></td>';
								html += '</tr><tr height="5px"></tr>';
				    			html += '</table>';
				    			$("#listForm").append(html);
							}
						}
						top.$.jBox.closeTip();
						isLoadOver = 0;
						var loadHtml = "<p>已加载全部数据...<p>";
						$(".loadMore").html(loadHtml);
						$(".loadMore").hide();
					},
					failure: function(){
						top.$.jBox.closeTip();
					}
				});
			}, 500);
			isLoadOver = 1;
		}
		
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
        //保存排序
        function updateSort() {
	    	$("#listForm").attr("action", "${ctx}/ivm/product/updateSort");
	    	$("#listForm").submit();
    	}
		//伸展查询条件
		function telescopic(obj){
			if($(obj).html()=="︾展开更多条件"){
				$(obj).html("︽收起");
				$("tr[id='moreCondition']").each(function(){
					$(this).show();
				});
			}else{
				$(obj).html("︾展开更多条件");
				$("tr[id='moreCondition']").each(function(){
					$(this).hide();
				});
			}
		}
		//选择一级分类
		function checkOneClassify(obj,id){
			$("#pageSize").val(10);
			$("#oneClassify").val(id);
			$("#twoClassify").val('');
			$('#searchForm').submit();
			//处理style
		}
		//选择二级分类
		function checkTwoClassify(obj,id){
			$("#pageSize").val(10);
			$("#twoClassify").val(id);
			$('#searchForm').submit();
		}
		//增加分类
		function addClassify(type){
			if(type == 1){//一级分类
				top.$.jBox.defaults.top="8%";
				top.$.jBox.open("iframe:${ctx}/ivm/product/classify/showAddClassify?level=1", "添加一级分类",$(top.document).width()-700,$(top.document).height()-100,{
					buttons:{"确定":false}, loaded:function(h){
						$(".jbox-content", top.document).css("overflow-y","hidden");
					}
				});
			}else{//二级分类
				var oneClassify = $("#oneClassify").val();
				top.$.jBox.defaults.top="8%";
				top.$.jBox.open("iframe:${ctx}/ivm/product/classify/showAddClassify?level=2&parent.id="+oneClassify, "添加二级分类",$(top.document).width()-700,$(top.document).height()-100,{
					buttons:{"确定":false}, loaded:function(h){
						$(".jbox-content", top.document).css("overflow-y","hidden");
					}
				});
			}
		}
		//排序
		function sort(obj,p_name){
			var orderBy = "";
			var name = $(obj).text();
			if(name.indexOf("︿")>0){
				name = name.replace("︿","﹀");
				$(obj).text(name);
				orderBy = "desc";
			}else if(name.indexOf("﹀")>0){
				name = name.replace("﹀","︿");
				$(obj).text(name);
				orderBy = "asc";
			}else{
				$("#sortSearch li").each(function(){
					if($(this).text().indexOf("︿")>0 || $(this).text().indexOf("﹀")>0){
						var text = $(this).text();
						var val = text.substr(0,text.length-1)
						$(this).text(val);
						$(this).removeClass("bg_white");
					}
				});
				$(obj).text(name+"︿");
				$(obj).addClass("bg_white");
				orderBy = "asc";
			}
			$('#type').val(1);
			$('#sortName').val('');
			$('#orderBy').val('');
			if(p_name != ''){
				$('#sortName').val(p_name);
				$('#orderBy').val(orderBy);
				$('#searchForm').submit();
			}
		}
		//打开销售状态入口
		function openSaleState(id){
			top.$.jBox.defaults.top="25%";
			top.$.jBox.open("iframe:${ctx}/ivm/product/showOpenState?id="+id, "销售状态",$(top.document).width()-800,$(top.document).height()-300,{
				buttons:{"确定":false}, loaded:function(h){
					$(".jbox-content", top.document).css("overflow-y","hidden");
				}
			});
		}
		//打开付款方式入口
		function openPayState(id){
			top.$.jBox.defaults.top="25%";
			top.$.jBox.open("iframe:${ctx}/ivm/product/showPayState?id="+id, "支付方式",$(top.document).width()-800,$(top.document).height()-300,{
				buttons:{"确定":false}, loaded:function(h){
					$(".jbox-content", top.document).css("overflow-y","hidden");
				}
			});
		}
		//打开商品入库入口
		function openIntoInventory(id){
			top.$.jBox.defaults.top="8%";
			top.$.jBox.open("iframe:${ctx}/ivm/inventory/showIntoInventory?productId="+id, "商品入库",$(top.document).width()-700,$(top.document).height()-100,{
				buttons:{"确定":false}, loaded:function(h){
					$(".jbox-content", top.document).css("overflow-y","hidden");
				}
			});
		}
		//打开商品出库入口
		function openOutInventory(id){
			top.$.jBox.defaults.top="8%";
			top.$.jBox.open("iframe:${ctx}/ivm/inventory/showOutInventory?productId="+id, "商品出库",$(top.document).width()-700,$(top.document).height()-100,{
				buttons:{"确定":false}, loaded:function(h){
					$(".jbox-content", top.document).css("overflow-y","hidden");
				}
			});
		}
		//打开摸价周几设置入口
		function openPriceCycleSet(id){
			top.$.jBox.defaults.top="25%";
			top.$.jBox.open("iframe:${ctx}/ivm/product/showPriceCycleSet?id="+id, "摸价周期",$(top.document).width()-800,$(top.document).height()-300,{
				buttons:{"确定":false}, loaded:function(h){
					$(".jbox-content", top.document).css("overflow-y","hidden");
				}
			});
		}
		//打开进出库记录入口
		function showInOrOutDetail(id, name){
			top.$.jBox.defaults.top="8%";
			top.$.jBox.open("iframe:${ctx}/ivm/inventory/showInOrOutDetail?productId="+id, name+"_进出库记录",$(top.document).width()-500,$(top.document).height()-100,{
				buttons:{"确定":false}, loaded:function(h){
					$(".jbox-content", top.document).css("overflow-y","hidden");
				}
			});
		}
		//打开原价/现价/进价记录入口type=1:原价,type=2:现价,type=3:进价
		function openPrice(id, name, type){
			var title = "进价";
			if(type == 1){
				title = "原价";
			}else if(type == 2){
				title = "现价";
			}
			top.$.jBox.defaults.top="8%";
			top.$.jBox.open("iframe:${ctx}/ivm/product/showMarketPrice?product.id="+id+"&type="+type, name+"_"+title+"记录",$(top.document).width()-500,$(top.document).height()-100,{
				buttons:{"确定":false}, loaded:function(h){
					$(".jbox-content", top.document).css("overflow-y","hidden");
				}
			});
		}
		//打开商品详情入口
		function showProductDetail(id){
			top.$.jBox.defaults.top="8%";
			top.$.jBox.open("iframe:${ctx}/ivm/product/showProductDetail?id="+id, "商品详情",$(top.document).width()-500,$(top.document).height()-100,{
				buttons:{"确定":false}, loaded:function(h){
					$(".jbox-content", top.document).css("overflow-y","hidden");
				}
			});
		}
		//打开销售市场入口
		function showProductSupplier(id){
			top.$.jBox.defaults.top="25%";
			top.$.jBox.open("iframe:${ctx}/ivm/product/showProductSupplier?id="+id, "销售市场",$(top.document).width()-800,$(top.document).height()-300,{
				buttons:{"确定":false}, loaded:function(h){
					$(".jbox-content", top.document).css("overflow-y","hidden");
				}
			});
		}
		
		function editForm(id){
			window.location.href="${ctx}/ivm/product/form?id="+id+"&searchParam="+URLencode($("#searchParam").val())+"&oneClassify="+$("#oneClassify").val()
								+"&twoClassify="+$("#twoClassify").val()+"&sortName="+$("#sortName").val()+"&orderBy="+$("#orderBy").val()+"&type="+$("#type").val();
		}
		//返回顶部
		function gotoTop(){
		    $(".gotoTop").click(//定义返回顶部点击向上滚动的动画
		        function(){$('html,body').animate({scrollTop:0},500);
		    });
		    //为窗口的scroll事件绑定处理函数
		    $(window).scroll(function(){
		        //获取窗口的滚动条的垂直位置
		        var s = $(window).scrollTop();
		        //当窗口的滚动条的垂直位置大于页面的最小高度时，让返回顶部元素渐现，否则渐隐
		        if( s > 500){
		            $(".gotoTop").show();
		        }else{
		            $(".gotoTop").hide();
		        }
		    });
		};
		//全选
		function selectAll(){
			$("input[name='productId']").each(function(){
				$(this).attr("checked", $("#select_all").is(':checked'));
			});
			if($selectAll){
				$selectAll= false;
			}else{
				$selectAll= true;
			}
		}
		//商品导出
		function exportProduct(){
			if($("input[name='productId']:checked").length==0){
				showJBoxMess("请选择要导出的商品.","error");
				return;
			}
			var productIds = "";
			$("input[name='productId']").each(function(){
				if($(this).is(":checked")){
					productIds+=","+$(this).val();
				}
			});
			productIds = productIds.substring(1);
			$("input[id='productIds']").val(productIds);
			var param = "productIds="+$("input[id='productIds']").val();
			if($selectAll){//如果是全选，则根据查询条件全部导出
				var param = "pageNo=1"+"&pageSize=9999";
				param += "&oneClassify="+$("#oneClassify").val();
				param += "&twoClassify="+$("#twoClassify").val();
				param += "&sortName="+$("#sortName").val();
				param += "&orderBy="+$("#orderBy").val();
				param += "&openState="+$("#openState").val();
				param += "&toPay="+$("#toPay").val();
				param += "&isPurchase="+$("#isPurchase").val();
				param += "&stockState="+$("#stockState").val();
				param += "&searchParam="+URLencode($("#searchParam").val());
			}
			top.$.jBox.confirm("确认要导出商品吗？","系统提示",function(v,h,f){
				if(v=="ok"){
					$.ajax({
						type: 'post',
						url: '${ctx}/ivm/product/export',
						data: param,
						dataType: 'json',
						success: function(data){
							if(data.status==200){
								document.location.href= '${ctx}/download?filePath='+URLencode(data.message);
							}else{
								showJBoxMess(data.message,"error");
							}
						},
						failure: function(){
							showJBoxMess("操作失败","error");
						}
					});
				}
			},{buttonsFocus:1});
			top.$('.jbox-body .jbox-icon').css('top','55px');
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/ivm/product/">商品列表</a></li>
		<shiro:hasPermission name="ivm:product:edit"><li><a href="${ctx}/ivm/product/form">添加商品</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="product" action="${ctx}/ivm/product/" method="post" class="breadcrumb form-search">
		<input type="hidden" id="productIds" name="productIds" value=""/>
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<input id="searchParam" name="searchParam" type="text" value="${searchParam }" style="width: 410px;" placeholder="请输入商品名称、商品编号、商品标签"/>
		&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="搜索"/>
		&nbsp;<input id="btnSubmit" class="btn btn-primary" type="button" value="保存排序" onclick="updateSort();"/>
		&nbsp;<input id="btnSubmit" class="btn btn-primary" type="button" value="商品导出" onclick="exportProduct();"/>
	<!-- 
	</form:form>
	<form:form id="searchForm1" modelAttribute="product" action="${ctx}/ivm/product/" method="post" class="breadcrumb form-search" style="margin-top:-15px">
	 -->
		<input type="hidden" id="oneClassify" name="oneClassify" value="${oneClassify }"/>
		<input type="hidden" id="twoClassify" name="twoClassify" value="${twoClassify }"/>
		<input type="hidden" id="type" name="type" value="${type }"/>
		<input type="hidden" id="sortName" name="sortName" value="${sortName }"/>
		<input type="hidden" id="orderBy" name="orderBy" value="${orderBy }"/>
		<ul class="nav nav-tabs" style="margin-bottom: 0px;margin-top: 5px;" id="one">
			<li class="${oneClassify==''?'active':''}"><a href="#" onclick="checkOneClassify(this,'')">全部</a></li>
			<c:forEach items="${fns:getClassifyOneList()}" var="classify">
			<li class="${classify.id==oneClassify?'active':''}"><a href="#" onclick="checkOneClassify(this,'${classify.id}')">${classify.name }</a></li>
			</c:forEach>
			<li class="display-none"><label class="color-red" onclick="addClassify(1)">+增加</label></li>
		</ul>
		<table width="100%" cellpadding="0" cellspacing="0" border="0">
			<tr>
				<td class="twoClass"><label class="${twoClassify==''?'bg_color':'' }" onclick="checkTwoClassify(this,'')">全部</label>
					<c:forEach items="${fns:getClassifyTwoList(oneClassify)}" var="classifyTwo">
						<label class="${classifyTwo.id==twoClassify?'bg_color':''}" onclick="checkTwoClassify(this,'${classifyTwo.id}')">${classifyTwo.name }</label>
					</c:forEach>
					<!-- label class="color-red display-none" onclick="addClassify(2)">+增加</label -->
				</td>
			</tr>
			<tr style="border-bottom: 1px solid #DDD">
				<td align="right">
					<label onclick="telescopic(this)" id="lable_more">︾展开更多条件</label>
				</td>
			</tr>
			<tr id="moreCondition">
				<td style="padding-top: 5px;"><label>销售状态：</label>
					<form:select id="openState" path="openState" class="input-small">
						<form:option value="" label="请选择"/>
						<form:options items="${fns:getDictList('sale_state')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
					</form:select>
					<label>定价状态：</label>
					<form:select id="" path="" class="input-small">
						<form:option value="" label="请选择"/>
						<form:options items="${fns:getDictList('warn_state')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
					</form:select>
					<label>摸价情况：</label>
					<form:select id="" path="" class="input-small">
						<form:option value="" label="请选择"/>
						<form:options items="${fns:getDictList('price_status')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
					</form:select>
				</td>
			</tr>
			<tr id="moreCondition">
				<td style="padding-top: 5px;">
					<label>支持到付：</label>
					<form:select id="toPay" path="toPay" class="input-small">
						<form:option value="" label="请选择"/>
						<form:options items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
					</form:select>
					<label>库存方式：</label>
					<form:select id="stockState" path="stockState" class="input-small">
						<form:option value="" label="请选择"/>
						<form:options items="${fns:getDictList('stock_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
					</form:select>
					<label>是否限购：</label>
					<form:select id="isPurchase" path="isPurchase" class="input-small">
						<form:option value="" label="请选择"/>
						<form:options items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
					</form:select>
					&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" onclick="$('#type').val(1);" value="查询"/>
				</td>
			</tr>
			<tr id="moreCondition" style="border-bottom: 1px solid #DDD">
				<td align="right">
					<label>排序</label>
				</td>
			</tr>
			<tr id="moreCondition" style="border-bottom: 1px solid #DDD">
				<td>
					<label style="float: left;border-right: 1px solid #DDD;padding: 5px 0px;cursor: auto">排序方式：</label>
					<ul id="sortSearch">
						<li onclick="sort(this,'sort')" style="cursor: pointer;">排序号</li>
						<li onclick="sort(this,'name')" style="cursor: pointer;">商品名</li>
						<li onclick="sort(this,'price')" style="cursor: pointer;">价格</li>
						<li onclick="sort(this,'')" style="cursor: pointer;">售出</li>
						<li onclick="sort(this,'')" style="cursor: pointer;">浏览</li>
					</ul>
				</td>
			</tr>
		</table>
	</form:form>
	<tags:message content="${message}"/>
	<table id="contentTable" class="table table-bordered table-condensed" style="border-top: none; border-right: none; border-left: none; margin-bottom: 0px; padding-bottom: 5px;">
		<tr>
			<td><input type="checkbox" id="select_all" name="select_all" value="全选" onclick="selectAll();" style="margin-left: 22px;"/>全选</td>
		</tr>
	</table>
	<form id="listForm" method="post">
	<c:forEach items="${page.list}" var="product" varStatus="vs">
	<table id="contentTable" class="table table-bordered table-condensed" style="border-top: 0px;margin-bottom:5px">
		<colgroup>
			<col width="50px"><col width="169px"/><col width="119px"/><col width="119px"/><col width="119px"/><col width="119px"/><col width="119px"/><col width="305px"/>
		</colgroup>
		<tr>
			<td rowspan="5" style="text-align: center;"><input type="checkbox" id="productId" name="productId" value="${product.id }" /></td>
			<td rowspan="5"><a href="javascript:" onclick="editForm('${product.id}')"><img id="photo" src="${ctx}/download?filePath=${product.logoUrl }" style="width:149px;height:96px " /></a></td>
			<td>${product.code}</td>
			<td colspan="2"><a href="javascript:" onclick="editForm('${product.id}')">${product.name}</a></td>
			<td><label class="color-green" onclick="openSaleState('${product.id}')">${product.openState==1?'正在销售':'待售' }</label></td>
			<td><label class="color-green" onclick="openIntoInventory('${product.id}')">入库</label></td>
			<td rowspan="5">
				<input type="hidden" name="ids" value="${product.id}"/>
				<!--<shiro:hasPermission name="ivm:product:edit">
				排序号：<input name="sorts" type="text" value="${product.sort}" style="width:50px;margin:0;padding:0;text-align:center;" class="required digits">
				</shiro:hasPermission>-->
				<a href="javascript:" id="arrow-up" onclick="arrowUpTable(this)"><i class="icon-arrow-up"></i>上移</a>
				<a href="javascript:" id="arrow-down" onclick="arrowDownTable(this)"><i class="icon-arrow-down"></i>下移</a>
			</td>
		</tr>
		<tr>
			<td></td>
			<td colspan="2">${product.assisTitle}</td>
			<td><label class="color-green" onclick="showProductSupplier('${product.id}')">销售市场</label></td>
			<td><label class="color-green" onclick="openOutInventory('${product.id}')">库存处理</label></td>
		</tr>
		<tr>
			<td>原价：<label class="color-green" onclick="openPrice('${product.id}', '${product.name}', 1)">${product.originalPrice }</label>元</td>
			<td>现价：<label class="color-green" onclick="openPrice('${product.id}', '${product.name}', 2)">${product.price }</label>元</td>
			<td>进价：<label class="color-green" onclick="openPrice('${product.id}', '${product.name}', 3)">${product.tradePrice }</label>元</td>
			<td><label class="color-green" onclick="openPayState('${product.id}')">${product.toPay=='0'?'网付':'网付/到付' }</label></td>
			<td><label class="color-green" onclick="showInOrOutDetail('${product.id}', '${product.name}')">进出库记录</label></td>
		</tr>
		<tr>
			<td>毛利：<fmt:formatNumber value="${product.price-product.tradePrice }" pattern="#.##" minFractionDigits="2" /></td>
			<td>毛利率：<fmt:formatNumber value="${(product.price-product.tradePrice)*100/product.tradePrice }" pattern="#.##" minFractionDigits="2" />%</td>
			<td>损耗率：<fmt:formatNumber value="${(product.lossRate)*100/1.00 }" pattern="#.##" minFractionDigits="2" />%</td>
			<c:if test="${product.purchaseNum==0}">
				<td>不限购</td>
			</c:if>
			<c:if test="${product.purchaseNum>0}">
				<td>限购数量：${product.purchaseNum }</td>
			</c:if>
			<td></td>
		</tr>
		<tr>
			<td>售出：${product.saleNum }${product.productUnit.name }</td>
			<td>浏览：${product.scan }</td>
			<td>库存：${product.stock }</td>
			<td colspan="2">
				<input type="hidden" id="shopUrl${vs.index }" name="shopUrl" value="${fns:getWebUrlPath()}/shops/product/detail?id=${product.id}"/>
				<a href="javascript:" id="clip_button" data-clipboard-target="shopUrl${vs.index }">复制链接</a>
			</td>
		</tr>
		<tr height="5px"></tr>
	</table>
	</c:forEach>
	</form>
	<div class="gotoTop"></div>
	<div class="loadMore hidden">
		<p><a href="javascript:;" onclick="loadMore();">加载全部...</a></p>
	</div>
	<!-- div class="pagination">${page}</div -->
</body>
</html>
